<?php
namespace app\common\model;

class PlatformPushLogLog extends Base
{
    protected $table = 'platform_push_log_logs';

    protected static function init()
    {

    }

    public function getCreateTimeLabelAttr($value, $data)
    {
        if (empty($data['create_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['create_time']);
    }

    public function getStatusTimeLabelAttr($value, $data)
    {
        if (empty($data['status_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['status_time']);
    }

    public function getPlatformIdLabelAttr($value, $data)
    {
        $platform = Platform::get(array('id' => $data['platform_id']));

        if (empty($platform)) {
            return '';
        }

        return $platform['name'];
    }

    public function getIdCardAttr($value, $data)
    {
        $info = Info::where('id', $data['info_id'])->find();

        if (empty($info)) {
            return '未知';
        }

        if ($data['status'] == 1) {
            return $info['id_card'];
        }

        $id_card = substr($info['id_card'], 0, 4) . str_repeat('*', strlen($info['id_card']) - 8). substr($info['id_card'],-4);
        return $id_card;

    }

    public function getApplyNameAttr($value, $data)
    {
        $info = Info::where('id', $data['info_id'])->find();

        if (empty($info)) {
            return '未知';
        }

        return $info['apply_name'];
    }

    public function getPhoneAttr($value, $data)
    {
        $member = Member::where('id', $data['member_id'])->find();

        if (empty($member)) {
            return '未知';
        }

        if ($data['status'] == 1) {
            return $member['phone'];
        }

        return substr($member['phone'], 0, 3) . str_repeat('*', strlen($member['phone']) - 7). substr($member['phone'],-4);
    }

    public function getStatusArrAttr($value, $data)
    {
        switch ($data['status']) {
            case 1:
                $result['status_label'] = '已同意';
                $result['status_class'] = 'layui-btn-default';
                break;
            case -1:
                $result['status_label'] = '已拒绝';
                $result['status_class'] = 'layui-btn-danger';
                break;
            default:
                $result['status_label'] = '未处理';
                $result['status_class'] = 'layui-btn-primary';
                break;
        }

        return $result;
    }

    public function getStatusMoneyLabelAttr($value, $data)
    {
        if ($data['status'] == 1) {
            return $data['status_money'];
        }

        return '0';
    }



}